﻿using Freebase4net.Interfaces;
using Freebase4net.Operators.Bases;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Freebase4net.Operators
{
    public class AndOperator : OperatorBase, IOperator
    {
        private string _value1, _value2;

        public AndOperator(string value1, string value2)
            : base(value1 + "###" + value2)
        {
            _value1 = value1;
            _value2 = value2;
        }

        public string CreateJson(string key)
        {
            try
            {
                StringBuilder builder = new StringBuilder();

                builder.AppendFormat("\"{0}\":\"{1}\",", key, _value1);
                builder.AppendLine();
                builder.AppendFormat("\"and:{0}\":\"{1}\"", key, _value2);

                return builder.ToString();
            }
            catch (Exception e)
            {
                throw new OperatorArgumentException("string");
            }
        }

        public override bool IncludeKeyWithNull
        {
            get { return false; }
        }
    }
}
